package com.huang.mapper;

import com.huang.entity.Film;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FilmMapper {

    @Select("select * from film")
    List<Film> queryAll();

    @Select("select * from film where film_id=#{filmId}")
    Film selectById(Integer filmId);

    @Select("select * from film where title like concat('%',#{title},'%')")
    List<Film> selectByTitle(String title);

    @Insert("insert into film values(null,#{title},#{description},#{releaseYear}," +
            "#{languageId},#{originalLanguageId},#{rentalDuration},#{rentalRate}," +
            "#{length},#{replacementCost},#{rating},#{specialFeatures},#{lastUpdate})")
    void insertOne(Film film);

    @Update("update film set title=#{title},description=#{description}," +
            "release_year=#{releaseYear},language_id=#{languageId}," +
            "original_language_id=#{originalLanguageId},rental_duration=#{rentalDuration}," +
            "rental_rate=#{rentalRate},length=#{length},replacement_cost=#{replacementCost}," +
            "rating=#{rating},special_features=#{specialFeatures},last_update=#{lastUpdate}")
    void updateOne(Film film);


    @Delete("delete from film where film_id=#{filmId}")
    void deleteOne(Integer filmId);
}
